package file;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.io.File;
import java.io.FileFilter;
import java.net.FileNameMap;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        //获取当前目录中名字以"."开始的所有子项
        File dir = new File(".");
        if (dir.isDirectory()){
            FileFilter filter = new FileFilter() {
                /*
                定义过滤规则，当参数file符合过滤要求那么accept方法应该当返回
                true

                 */




                public boolean accept(File file) {
                    String fileName = file.getName();
                    System.out.println("正在过滤" + fileName);
                    return fileName.startsWith(".");
                }
            };
            File[] subs =dir.listFiles(filter);
            System.out.println("满足过滤器要求的子项共"+subs.length+"个");
            for (int i = 0; i <subs.length ; i++) {
                System.out.println(subs[i].getName());
            }

        }







    }
}
